<template>
	<view class="h100b" :style="{ backgroundImage: 'url(' + cosImageUrl('head_bg.png',true) + ')' }">
		<!-- 顶部导航 -->
		<u-sticky>
			<view class="zdex9 bgdce6fe">
				<view class="">
					<view class="" :style="{'paddingTop':statusBarHeigh + 'px',}">
						<view class="flex alicen pl20" :style="{'height':menuButtonInfo.height + 'px',}">
							<view class="w40b">
								<u-icon name="arrow-left" color="#070707" size="18" @click="goback()"></u-icon>
							</view>
							<view class="fz30 bold">{{title}}</view>
						</view>
					</view> 
				</view>
				<view class="pt20 ">
					<view class="flex  alicen evenly">
						<view class="mr10  flex alicen ius10">
							<view @click="subsectionChange(0)" :class="showType == 'grade'?'w30b':'w100b' "
								class="pt10 mr10 bgfff flex alicen mr10 pb10 pl20 pr20  nowrap col99 fz24 txtcen ius10 border1 boreb">
								<view class="mr10 w100 text-word-break-1">{{provinceName||'院校省份'}}</view>
								<u-icon name="arrow-down" color="#070707" size="14"></u-icon>
							</view>
							<view  @click="subsectionChange(1)"
								class="pt10 ml20 bgfff mr10 flex alicen pr20 mr10 pb10 pl20  nowrap col99 fz24 w100b txtcen ius10 border1 boreb">
								<view class="mr10 w100 text-word-break-1">{{schoolTypesName|| '类型/性质'}}
								</view>
								<u-icon name="arrow-down" color="#070707" size="14"></u-icon>
							</view>
							<view @click="subsectionChange(2)"
								class="pt10 ml20 bgfff mr10 flex alicen mr10 pr20 pb10 pl20  nowrap col99 fz24 w100b txtcen ius10 border1 boreb">
								<view class="mr10 w100 text-word-break-1">{{schoolLevelName||'院校特色'}}</view>
								<u-icon name="arrow-down" color="#070707" size="14"></u-icon>
							</view>
							
						</view>
						<view class="pt10 pb10 pl20 pr20 bgff000 colff fz24 ius10 nowrap flexCenter"
							@click="querySearool()">查询
						</view>
					</view>
					<!-- 冲 争 稳 守 保底 -->
					<view class="flexCenter   fz28 pl20 pb10  pr20" v-if="showType == 'grade' ">
						<view class="nowrap  mr20 flex alicen" :class="currIndex == i?'bgfff col40':'' ">
							<view class="pl8 ius10 pr8  pt10" @tap.stop="chagetap('c')"
								:class="currIndex == 'c'?' col40':'' ">冲{{all.c}}</view>
							<view class="pl8 ius10 pr8  pt10" @tap.stop="chagetap('z')"
								:class="currIndex == 'z'?' col40':'' ">争{{all.z}}</view>
							<view class="pl8 ius10 pr8  pt10" @tap.stop="chagetap('w')"
								:class="currIndex == 'w'?' col40':'' ">稳{{all.w}}</view>
							<view class="pl8 ius10 pr8  pt10" @tap.stop="chagetap('s')"
								:class="currIndex == 's'?' col40':'' ">守{{all.s}}</view>
							<view class="pl8 ius10 pr8  pt10" @tap.stop="chagetap('b')"
								:class="currIndex == 'b'?' col40':'' ">保{{all.b}}</view>
						</view>
					</view>
				</view>


				<!-- 温馨提示 -->
				<view v-if="showType == ''" class="fz24 colb6 ml20 mr20 mt10"> <text
						class="col40 ml10">温馨提示:</text>院校或专业录取数据未满三年的,系统显示的概率会有偏差,请自行分析或咨询老师。
				</view>
			</view>
			<!-- #ifdef H5 -->
			<view class="pb60"></view>
			<!-- #endif -->
		</u-sticky>
		<!-- 卡片内容 -->
		<scroll-view scroll-y="true" class="hcalc" v-if="suarr&&suarr.length > 0" @scrolltolower="scrolltolower">
			<view class=" relative pt10 pb20 bgfff pl20 pr20 ius10 ml20 mt10 mr20" v-for="(item,i) in suarr" :key="i"
				@click="schoolDetail(item)">
				<view class="absolute  pr10 pl30 alicen flex  h60 bgsize100b no-repeat t0 r0"
					:style="{ backgroundImage: 'url(' + cosImageUrl('bage.png',true) + ')' }">
					<text class="fz24 bold colff">{{item.submitRate}}%</text>
				</view>

				<view class="flex between alicen w85b">
					<view class=""> <text class="fz30 bold mr20">{{item.sname}}</text> <text
							class="fz20">院校综合实力排行(供参考){{item.sranking}}</text> </view>
					<!-- <view class="bold fz24 bold nowrap" v-if="showType !== 'grade' ">投档概率</view> -->
				</view>
				<view class="mb10 fz28 mt10 col33">院校代码: <text>{{item.scode}}</text> </view>
				<view class="mb10 fz28 col33">类型/性质: <text>{{item.collegeLevel||'--'}}</text> </view>
				<view class="flex alicen">
					<view class="mb10 fz28 col33">院校专业组: <text>{{item.zyz}}</text> </view>
					<view class="mb10 fz28 col33 ml20">再选科目: <text>{{item.zxkm}}</text> </view>
				</view>
				<view class="pb20"></view>
				<view class="flex alicen fz20">
					<view class="flex1 border1  boreb pt20 pb20 flexCenter nowrap">年份</view>
					<view class="flex1 border1  boreb pt20 pb20 flexCenter nowrap">分数线</view>
					<view class="flex1 border1  boreb">
						<view class="nowrap pad4 flexCenter bgff000 colff">录取最低分</view>
						<view class="nowrap  pad4 flexCenter bg0055ff colff">最低分排位</view>
					</view>
					<view class="flex1 border1  boreb">
						<view class="nowrap  pad4 flexCenter bgff000 colff">您的同位分</view>
						<view class="nowrap  pad4 flexCenter bg0055ff colff">您的名次</view>
					</view>
					<view class="flex1 border1  boreb">
						<view class="nowrap  pad4 flexCenter bgff000 colff">录取平均分</view>
						<view class="nowrap  pad4 flexCenter bg0055ff colff">平均分名次</view>
					</view>
					<view class="flex1 border1  boreb">
						<view class="nowrap  pad4 flexCenter bgff000 colff">计划招生数</view>
						<view class="nowrap  pad4 flexCenter bg0055ff colff">录取数</view>
					</view>
					<view class="flexCenter border1 boreb nowrap pad20">收藏</view>
				</view>
				<view class="flex alicen border1 boreb">
					<view class="w88b">
						<view class="flex alicen fz20" v-for="(item1,i1) in item.yearsData">
							<view class="flex1 bdr1_bottom  bdl1-left1 boreb pt20 pb20 flexCenter nowrap">{{item1.year||'--'}}</view>
							<view class="flex1 bdr1_bottom  bdl1-left1 boreb pt20 pb20 flexCenter nowrap">{{item1.gradeLine||'--'}}</view>
							<view class="flex1 bdl1-left1 boreb">
								<view class="nowrap  pad4 flexCenter bdr1_bottom bored  col40">{{item1.minGrade||'--'}}</view>
								<view class="nowrap  pad4 flexCenter bdr1_bottom bored col359eff">{{item1.minGradeSeq||'--'}}
								</view>
							</view>
							<view class="flex1 bdl1-left1 boreb">
								<view class="nowrap  pad4 flexCenter bored bdr1_bottom col40">{{item1.seqGrade||'--'}}</view>
								<view class="nowrap  pad4 flexCenter bored bdr1_bottom col359eff">{{item1.seq||'--'}}</view>
							</view>
							<view class="flex1 bdl1-left1 boreb">
								<view class="nowrap  pad4 flexCenter bored bdr1_bottom col40">{{item1.avgGrade||'--'}}</view>
								<view class="nowrap  pad4 flexCenter bored bdr1_bottom col359eff">{{item1.avgGradeSeq||'--'}}
								</view>
							</view>
							<view class="flex1 bdl1-left1 bdl1-rigth1 boreb bdr1_bottom">
								<view class="nowrap  pad4 flexCenter bored bdr1_bottom col40">
									{{item1.planSubmitAdmission.split('-')[0]||'--'}}
								</view>
								<view class="nowrap pad4 flexCenter col359eff ">
									{{item1.planSubmitAdmission.split('-')[1]||'--'}}
								</view>
							</view>
						</view>
					</view>
					<view class="w12b fz18">
						<view class="flexCenter  nowrap " @tap.stop="favorite(item)">收藏</view>
					</view>
				</view>
			</view>
		</scroll-view>
		<view class="" v-else>
			<u-empty mode="list"></u-empty>
		</view>
		<com-popup :showPop="popObj.showRightPop" @popStatus="(i) => {popObj.showRightPop = i,popObj.isLoad = {}}">
			<com-selectList :flag="flag" :typesign="popObj.typesign" :popTypeName="popObj.popTypeName"
				:popTypeValue="popObj.popTypeValue" :list="popObj.popList" :title="popObj.popTitle" @submit="submitPop"
				v-if="popObj.isLoad.selectList">
			</com-selectList>
		</com-popup>
	</view>
</template>

<script>
	import config from "@/config.js";
	import {
		province_list,
		school_level,
		school_types
	} from "@/utils/api/dict.js"
	export default {
		data() {
			return {
				currIndex: '',
				all: {}, //分数合集
				showType: '', //判断是否显示分数合集
				config: config,
				flag: false, //判断单选多选
				provinceName: '', //省份schoolTypes
				schoolTypesName: '', //性质特色
				schoolLevelName: '', //院校特色
				suarr: [], //查询到的数组
				title: '找大学', //标题
				subsectionCurrent: 0,
				popObj: {
					popTypeName: "",
					popTypeValue: "",
					showRightPop: false,
					popTitle: "",
					typesign: '', //自定义标识
					popList: [],
					isLoad: {}
				},
				model1: {
					searchInfo: {
						province: "", //省份
						schoolTypes: "", //类型性质
						schoolCode2: "", //特点
						batch: "本科普通批",
						userId: this.$store.state.userId,
						pageNum: 1,
						schoolCodeInp: "",
						schoolNameInp: "",
						submitType: "L",
						provinceName: "全部"
					}
				},
			}
		},
		onLoad(options) {
			if (options.pageType && options.showType) {
				this.currIndex = options.pageType
				this.showType = options.showType
			}
			if (options.params) {
				console.log('params', JSON.parse(options.params))
				let obj = JSON.parse(options.params)
				this.provinceName = obj.provinceName
				this.schoolTypesName = obj.schoolTypesName
				this.schoolLevelName = obj.schoolLevelName
				this.title = '专业组分析'
				this.Searool();
			}
			this.showSubmit() //分数
		},
		onUnload() {
			this.provinceName = ''
			this.schoolTypesName = ''
			this.schoolLevelName = ''
			// this.deleteData('provinceName')
			// this.deleteData('province')
			// this.deleteData('schoolTypes')
			// this.deleteData('schoolCode2')
		},
		onShow() {
			this.model1.searchInfo.pageNum = 1
			this.suarr = []
			this.$store.dispatch('clearState');
			this.Searool();
		},
		onUnload() {
			this.$store.dispatch('clearState');
		},
		computed: {
			//省份
			province() {
				return this.$store.state.province
			},
			schoolTypes() {
				return this.$store.state.schoolTypes
			},
			schoolLevel() {
				return this.$store.state.leveltype
			},
		},
		methods: {
			chagetap(item) {
				if (item == this.currIndex) return;
				this.currIndex = item
				this.suarr = []
				this.Searool();
			},
			subsectionChange(index) {
				if (index == 0) return this.selectProvince();
				if (index == 1) return this.selectCategory(); //请求类别性质
				if (index == 2) return this.characteristics(); //请求院校特点
			},
			selectProvince() {
				this.popObj.popTypeName = "省份"
				this.popObj.popTypeValue = "可多选"
				this.popObj.typesign = "S" //自定义标识
				province_list({
					scrollstr: true
				}).then(res => {
					let temp = []
					res.map((item) => {
						let obj = {
							name: item.name,
							value: item.id
						}
						temp.push(obj)
					})
					this.popObj.popList = temp
					this.popObj.isLoad["selectList"] = true
					this.popObj.showRightPop = true
				})
			},
			// 请求类别性质
			selectCategory() {
				this.popObj.popTypeName = "类型/性质"
				this.popObj.popTypeValue = "可多选"
				this.popObj.typesign = "L" //自定义标识

				school_level("").then(res => {
					let temp = []
					res.data.map(item => {
						let obj = {
							name: item.dictLabel,
							value: item.dictValue
						}
						temp.push(obj)
					})
					this.popObj.popList = temp
					this.popObj.isLoad["selectList"] = true
					this.popObj.showRightPop = true
				})
			},
			//院校特点
			characteristics() {
				this.popObj.popTypeName = "院校特色"
				this.popObj.popTypeValue = "可多选"
				this.popObj.typesign = "Y" //自定义标识
				school_types("").then(res => {
					let temp = []
					res.data.map(item => {
						let obj = {
							name: item.dictLabel,
							value: item.dictValue
						}
						temp.push(obj)
					})
					this.popObj.popList = temp
					this.popObj.isLoad["selectList"] = true
					this.popObj.showRightPop = true
					this.flag = false
				})
			},
			selectBatch() {},
			submitPop(item) {
				console.log('item', item)
				this.display(item);
				this.popObj.popTypeName = null
				this.popObj.popTypeValue = null
				this.popObj.popTitle = null
				this.popObj.popList = []
				this.popObj.isLoad = {}
				this.popObj.showRightPop = false
				this.Searool()
			},
			searchool() {
				this.model1.searchInfo.pageNum = 1
				this.suarr = []
				this.Searool();
			},
			querySearool() {
				this.model1.searchInfo.pageNum = 1
				this.suarr = []
				this.Searool();
			},
			async showSubmit() {
				let params = {
					useId: this.readData('useId')
				}
				let shows = await this.request.get('/api/showSubmit', {
					params
				})
				if (shows.code == 200) {
					this.all = shows.data
				}
			},
			//查询
			async Searool(data = {}) {
				let params = {
					pageType:this.currIndex, //查可冲击 争取 稳 守 保底
					province:this.province, //省份
					schoolTypes:this.schoolLevel,
					schoolLevel:this.schoolTypes,
					schoolCode2: '',
					batch: '',
					userId: this.readData('useId'),
					pageNum: this.model1.searchInfo.pageNum,
					schoolCodeInp: '',
					schoolNameInp: this.model1.searchInfo.schoolNameInp || ''
				}
				let su = await this.request.get('/api/zhfx_list', {
					params
				});
				if (su.code == 200) {
					this.suarr = this.suarr.concat(this.processreArr(su.data.rows));
					console.log('数组', this.suarr)
				}
			},
			scrolltolower() {
				this.showloading();
				this.model1.searchInfo.pageNum++
				this.Searool();
			},
			//提交vuex
			display(item) {
				if (item.potypesignValue == 'S') {
					this.provinceName = this.mitprovince(item.val, 'name')
					let province = this.mitprovince(item.val, 'value')
					this.$store.commit('probtn', province)
				}
				if (item.potypesignValue == 'L') {
					this.schoolTypesName = this.mitprovince(item.val, 'name')
					let schoolTypesId = this.mitprovince(item.val, 'value')
					this.$store.commit('typebtn', schoolTypesId)
				}
				if (item.potypesignValue == 'Y') {
					this.schoolLevelName = this.mitprovince(item.val, 'name')
					let LevelId = this.mitprovince(item.val, 'value')
					this.$store.commit('Levelbtn', LevelId)
				}
			},
			//大学详情
			schoolDetail(item) {
				this.showloading();
				let params = {
					schoolCode: item.scode,
					zyz: item.zyz,
					userId: this.readData('useId'),
				}
				this.navgateTo('/pages/schoolDetail/schoolDetail', {
					params: JSON.stringify(params)
				})
				this.provinceName = ''
				this.schoolTypesName = ''
				this.schoolLevelName = ''
				this.$store.dispatch('clearState');
			},
			//收藏事件
			async favorite(item) {
				let params = {
					schoolCode: item.scode,
					zyz: item.zyz,
					userId: this.readData('useId')
				}
				let favres = await this.request.get('/api/addMyFavorite', {
					params
				})
				if (favres.code == 200) {
					this.successToShow(favres.msg)
				}
			}
		},

	}
</script>

<style lang="less">
	// #ifdef MP-WEIXIN
	.hcalc {
		height: calc(100ch - 30rpx);
		overflow: auto;
	}
	// #endif
	// #ifdef H5
	.hcalc {
		height: calc(100ch - 230rpx);
		overflow: auto;
	}
	// #endif
</style>